<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            height: 100px;
            background-color: #ccc;
            margin:25px 50px;
        }
        .box span{
            line-height: 100px;
            font-size: 60px;
            color: yellow;
            margin: 1px;
        }
    </style>
</head>
<body>
    <div class="box">
        <span>☆</span>
        <span>☆</span>
        <span>☆</span>
        <span>☆</span>
        <span>☆</span>
    </div>
    <script src="js/jquery-1.12.4.min.js"></script>
    <script>
   var $spans=$(".box span")
   var $box=$(".box")

   
//    $spans.mouseenter(function(){
//     $(this).html("★")
//    })
//    $spans.mouseleave(function(){
//     $(this).html("☆")
//    })


$spans.each(function(){
    // console.log($(this).index())
    $spans.mouseenter(function(){
    $(this).html("★").prevAll().html("★")
   })
   $spans.mouseleave(function(){
    $(this).html("☆")
   })
})
$box.mouseleave(function(){
    $spans.html("☆")
   })


    </script>
    
</body>
</html>